function show_svg(uid) {
    document.getElementById(uid).style.display = "inline";
}

function hidden_svg(uid) {
    document.getElementById(uid).style.display = "none";
}

document.getElementById("_user").innerText = getQueryVariable("username");
hidden_svg("svg_explist");

function user_clicked() {
    var obj = document.getElementById("follow-menu");
    if (obj.style.display === 'block') {
        obj.style.display = 'none';
        hidden_svg("svg_explist");
        show_svg("svg_list");
    } else {
        obj.style.display = 'block';
        hidden_svg("svg_list");
        show_svg("svg_explist");
    }
}

function iframe_refresh() {
    document.getElementById('iframe').contentWindow.location.reload();
}

function onItemClicked(str_url) {
    document.getElementById("dateTime").style.display = "none";
    document.getElementById("iframe").style.display = "block";
    if (document.getElementById("main_content").style.width !== "100%") {
        show_svg("svg_expand");
    }
    document.getElementById("iframe").src = str_url + "?username=" + getQueryVariable("username");
    setTimeout("iframe_refresh()", 300);
}

function style_main_content_expand() {
    document.getElementById("main_content").style.marginTop = "0";
    document.getElementById("main_content").style.marginLeft = "0";
    document.getElementById("main_content").style.width = "100%";
    document.getElementById("main_content").style.height = "100%";
    document.getElementById("main_content").style.zIndex = "1110";
}

function style_main_content_contract() {
    document.getElementById("main_content").style.marginTop = "8%";
    document.getElementById("main_content").style.marginLeft = "7%";
    document.getElementById("main_content").style.width = "84%";
    document.getElementById("main_content").style.height = "76%";
    document.getElementById("main_content").style.zIndex = "1001";
}

function svg_expand_clicked() {
    hidden_svg("logo");
    hidden_svg("user");
    show_svg("svg_contract");
    hidden_svg("svg_expand");

    document.getElementById("main_content").style.transition = "all 2s";
    setTimeout("style_main_content_expand()", 300);
}

function svg_contract_clicked() {
    hidden_svg("svg_contract");
    show_svg("svg_expand");

    setTimeout("style_main_content_contract()", 300);
    show_svg("logo");
    show_svg("user");
}

function getQueryVariable(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] === variable) {
            return pair[1];
        }
    }
    return false;
}

Date.prototype.format = function(fmt) {
    var o = {
        "y+": this.getFullYear, //年
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate(), //日
        "h+": this.getHours(), //小时
        "m+": this.getMinutes(), //分
        "s+": this.getSeconds() //秒
    };
    if (/(y+)/.test(fmt))
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt))
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}
setInterval("document.getElementById('dateTime').innerHTML = (new Date()).format('yyyy-MM-dd hh:mm:ss');", 1000);